import {useState} from "react";

//父传子数据
//1.父组件传递数据居子组件标签身上绑定属性
//2.子组件接收数据props的参数
//3.props是只读对象:子组件只能读取props中的数据，不能直接进行修改，父组件的数据只能由父组件修改
const Son = (props) => {
    console.log(props)
    return (
        <div>
            <h2>this is son</h2>
            {props.say}
            <h3>
                {props.name},
                {props.age},
                {props.sex},
            </h3>
        </div>
    )
}
export const App = () => {
    const [user] = useState({
        name: 'zhangsan',
        age: 18,
        sex: 'man'
    })
    const [data] = useState('hello,son!')
    return (
        <div>
            <h2>this is app</h2>
            <Son say={data} {...user}/>
        </div>
    )
}
